import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// 导入 
import path from "path"
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    port: 8888,  // 设置端口号
    // 设置跨域
    proxy: {
      '/api': {
        target: 'http://106.52.235.252:8101/',  //项目链接
        changeOrigin: true,//允许跨域
        rewrite: (path) => path.replace(/^\/api/, '') //将作为识别用途的/api字符串从请求路径中去掉
      },
    }
  },
  // 设置 文件重名
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src")
    }
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
})
